package com.dal.db.bean;

import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import org.apache.commons.lang3.ArrayUtils;
import static com.dal.db.StaticResource.AccountResource.FK_HASHCODE_TABLE_NAMES;
import static com.dal.db.StaticResource.AccountResource.SOURCE_COLUMN_NAMES;
import static com.dal.db.StaticResource.AccountResource.FK_SOURCE_TABLE_NAMES;
import static com.dal.db.StaticResource.AccountResource.HASHCODE_COLUMN_NAMES;
import java.sql.SQLException;
import static com.dal.db.StaticResource.AccountResource.FK_PINGYING_COLUMN_NAMES;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.SK_Plus;
import java.sql.ResultSet;
import java.util.Map;
import static com.dal.db.StaticResource.AccountResource.FK_PINGYING_TABLE_NAMES;
import static com.dal.db.StaticResource.AccountResource.SOURCE_COLUMN_REMARKS;
import com.dal.db.cache.PlatformCache;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import static com.dal.db.StaticResource.AccountResource.FK_SOURCE_COLUMN_NAMES;
import static com.dal.db.StaticResource.AccountResource.COLUMN_BASICTYPES;
import static com.dal.db.StaticResource.AccountResource.COLUMN_COLUMNTYPES;
import static com.dal.db.StaticResource.AccountResource.*;
import com.sojoys.artifact.build.data.base.BasePojo;
import static com.dal.db.StaticResource.AccountResource.COLUMN_CLASSTYPES;
import static com.dal.db.StaticResource.AccountResource.COLUMN_COUNT;
import com.sojoys.artifact.tools.ToolCopy;
import com.dal.db.cache.ChannelCache;
import com.alibaba.fastjson.JSONObject;
import com.dal.db.cache.ChannelAppCache;
import com.dal.db.cache.AccountCache;
import static com.dal.db.StaticResource.AccountResource.PINGYING_COLUMN_NAMES;
import static com.dal.db.StaticResource.AccountResource.FK_HASHCODE_COLUMN_NAMES;
import static com.dal.db.StaticResource.AccountResource.*;
/**
 * 账号表
 */
public class Account extends BasePojo<Account> {
	
	
	/**
	 * 索引值
	 */
	private String[] indexValues = new String[5];
	
	/**
	* id
	*/
	private String id;
	
	/**
	* 平台账号id
	*/
	private String accountId;
	
	/**
	* 渠道ID
	*/
	private int channelId;
	
	/**
	* 渠道APPID
	*/
	private int channelAppId;
	
	/**
	* 密码（是MD5加密后的）
	*/
	private String password;
	
	/**
	* 用户手动绑定的邮箱
	*/
	private String email;
	
	/**
	* 设备token
	*/
	private String deviceToken;
	
	/**
	* 设备名称
	*/
	private String deviceName;
	
	/**
	* 设备唯一ID
	*/
	private String deviceId;
	
	/**
	* SDK类型
	*/
	private String sdk;
	
	/**
	* SDK版本
	*/
	private String sdkVersion;
	
	/**
	* 系统名称
	*/
	private String osName;
	
	/**
	* 系统版本
	*/
	private String osVersion;
	
	/**
	* 手机号（限定唯一并且填充时进行唯一检测）
	*/
	private String phoneNumber;
	
	/**
	* 客户端版本号
	*/
	private String clientVersion;
	
	/**
	* 密保问题
	*/
	private String question;
	
	/**
	* 密保答案
	*/
	private String answer;
	
	/**
	* 管理员账号
	*/
	private boolean admin;
	
	/**
	* 游戏服id
	*/
	private String gameServerId;
	
	/**
	* 语言
	*/
	private String language;
	
	/**
	* ip地址
	*/
	private String ip;
	
	/**
	* 最后上线时间
	*/
	private java.util.Date lastOnlineTime;
	
	/**
	* 最后下线时间
	*/
	private java.util.Date lastOfflineTime;
	
	/**
	* 封禁状态（账号冻结、禁言等）
	*/
	private int state;
	
	/**
	* 在线状态
	*/
	private int onlineState;
	
	/**
	* 是否激活
	*/
	private boolean activate;
	
	/**
	* 创建时间
	*/
	private java.util.Date createDate;
	
	/**
	* 修改时间
	*/
	private java.util.Date modifiedDate;
	
	
	@Deprecated
	public static Account builder() {
		Account account = new Account();
		return account;
	}
	
	@Deprecated
	public Account() {
		super();
	}
	
	public Account(String id, String accountId, int channelId, int channelAppId, String password, String email, String deviceToken, String deviceName, String deviceId, String sdk, String sdkVersion, String osName, String osVersion, String phoneNumber, String clientVersion, String question, String answer, boolean admin, String gameServerId, String language, String ip, java.util.Date lastOnlineTime, java.util.Date lastOfflineTime, int state, int onlineState, boolean activate) {
		super();
		this.id = id;
		this.accountId = accountId;
		this.channelId = channelId;
		this.channelAppId = channelAppId;
		this.password = password;
		this.email = email;
		this.deviceToken = deviceToken;
		this.deviceName = deviceName;
		this.deviceId = deviceId;
		this.sdk = sdk;
		this.sdkVersion = sdkVersion;
		this.osName = osName;
		this.osVersion = osVersion;
		this.phoneNumber = phoneNumber;
		this.clientVersion = clientVersion;
		this.question = question;
		this.answer = answer;
		this.admin = admin;
		this.gameServerId = gameServerId;
		this.language = language;
		this.ip = ip;
		this.lastOnlineTime = lastOnlineTime;
		this.lastOfflineTime = lastOfflineTime;
		this.state = state;
		this.onlineState = onlineState;
		this.activate = activate;
		this.createDate = new java.util.Date();
		this.modifiedDate = new java.util.Date();
	}
	
	/**
	 * id
	 */
	public String getId() {return id;}
	
	/**
	 * id
	 */
	public Account setId(String id) {this.id = id;return this;}
	
	/**
	 * 平台账号id
	 */
	public String getAccountId() {return accountId;}
	
	/**
	 * 平台账号id
	 */
	public Account setAccountId(String accountId) {this.accountId = accountId;return this;}
	
	/**
	 * 渠道ID
	 */
	public int getChannelId() {return channelId;}
	
	/**
	 * 渠道ID
	 */
	public Account setChannelId(int channelId) {this.channelId = channelId;return this;}
	
	/**
	 * 渠道APPID
	 */
	public int getChannelAppId() {return channelAppId;}
	
	/**
	 * 渠道APPID
	 */
	public Account setChannelAppId(int channelAppId) {this.channelAppId = channelAppId;return this;}
	
	/**
	 * 密码（是MD5加密后的）
	 */
	public String getPassword() {return password;}
	
	/**
	 * 密码（是MD5加密后的）
	 */
	public Account setPassword(String password) {this.password = password;return this;}
	
	/**
	 * 用户手动绑定的邮箱
	 */
	public String getEmail() {return email;}
	
	/**
	 * 用户手动绑定的邮箱
	 */
	public Account setEmail(String email) {this.email = email;return this;}
	
	/**
	 * 设备token
	 */
	public String getDeviceToken() {return deviceToken;}
	
	/**
	 * 设备token
	 */
	public Account setDeviceToken(String deviceToken) {this.deviceToken = deviceToken;return this;}
	
	/**
	 * 设备名称
	 */
	public String getDeviceName() {return deviceName;}
	
	/**
	 * 设备名称
	 */
	public Account setDeviceName(String deviceName) {this.deviceName = deviceName;return this;}
	
	/**
	 * 设备唯一ID
	 */
	public String getDeviceId() {return deviceId;}
	
	/**
	 * 设备唯一ID
	 */
	public Account setDeviceId(String deviceId) {this.deviceId = deviceId;return this;}
	
	/**
	 * SDK类型
	 */
	public String getSdk() {return sdk;}
	
	/**
	 * SDK类型
	 */
	public Account setSdk(String sdk) {this.sdk = sdk;return this;}
	
	/**
	 * SDK版本
	 */
	public String getSdkVersion() {return sdkVersion;}
	
	/**
	 * SDK版本
	 */
	public Account setSdkVersion(String sdkVersion) {this.sdkVersion = sdkVersion;return this;}
	
	/**
	 * 系统名称
	 */
	public String getOsName() {return osName;}
	
	/**
	 * 系统名称
	 */
	public Account setOsName(String osName) {this.osName = osName;return this;}
	
	/**
	 * 系统版本
	 */
	public String getOsVersion() {return osVersion;}
	
	/**
	 * 系统版本
	 */
	public Account setOsVersion(String osVersion) {this.osVersion = osVersion;return this;}
	
	/**
	 * 手机号（限定唯一并且填充时进行唯一检测）
	 */
	public String getPhoneNumber() {return phoneNumber;}
	
	/**
	 * 手机号（限定唯一并且填充时进行唯一检测）
	 */
	public Account setPhoneNumber(String phoneNumber) {this.phoneNumber = phoneNumber;return this;}
	
	/**
	 * 客户端版本号
	 */
	public String getClientVersion() {return clientVersion;}
	
	/**
	 * 客户端版本号
	 */
	public Account setClientVersion(String clientVersion) {this.clientVersion = clientVersion;return this;}
	
	/**
	 * 密保问题
	 */
	public String getQuestion() {return question;}
	
	/**
	 * 密保问题
	 */
	public Account setQuestion(String question) {this.question = question;return this;}
	
	/**
	 * 密保答案
	 */
	public String getAnswer() {return answer;}
	
	/**
	 * 密保答案
	 */
	public Account setAnswer(String answer) {this.answer = answer;return this;}
	
	/**
	 * 管理员账号
	 */
	public boolean isAdmin() {return admin;}
	
	/**
	 * 管理员账号
	 */
	public Account setAdmin(boolean admin) {this.admin = admin;return this;}
	
	/**
	 * 游戏服id
	 */
	public String getGameServerId() {return gameServerId;}
	
	/**
	 * 游戏服id
	 */
	public Account setGameServerId(String gameServerId) {this.gameServerId = gameServerId;return this;}
	
	/**
	 * 语言
	 */
	public String getLanguage() {return language;}
	
	/**
	 * 语言
	 */
	public Account setLanguage(String language) {this.language = language;return this;}
	
	/**
	 * ip地址
	 */
	public String getIp() {return ip;}
	
	/**
	 * ip地址
	 */
	public Account setIp(String ip) {this.ip = ip;return this;}
	
	/**
	 * 最后上线时间
	 */
	public java.util.Date getLastOnlineTime() {return lastOnlineTime;}
	
	/**
	 * 最后上线时间
	 */
	public Account setLastOnlineTime(java.util.Date lastOnlineTime) {this.lastOnlineTime = lastOnlineTime;return this;}
	
	/**
	 * 最后下线时间
	 */
	public java.util.Date getLastOfflineTime() {return lastOfflineTime;}
	
	/**
	 * 最后下线时间
	 */
	public Account setLastOfflineTime(java.util.Date lastOfflineTime) {this.lastOfflineTime = lastOfflineTime;return this;}
	
	/**
	 * 封禁状态（账号冻结、禁言等）
	 */
	public int getState() {return state;}
	
	/**
	 * 封禁状态（账号冻结、禁言等）
	 */
	public Account setState(int state) {this.state = state;return this;}
	
	/**
	 * 在线状态
	 */
	public int getOnlineState() {return onlineState;}
	
	/**
	 * 在线状态
	 */
	public Account setOnlineState(int onlineState) {this.onlineState = onlineState;return this;}
	
	/**
	 * 是否激活
	 */
	public boolean isActivate() {return activate;}
	
	/**
	 * 是否激活
	 */
	public Account setActivate(boolean activate) {this.activate = activate;return this;}
	
	/**
	 * 创建时间
	 */
	public java.util.Date getCreateDate() {return createDate;}
	
	/**
	 * 创建时间
	 */
	protected Account setCreateDate(java.util.Date createDate) {this.createDate = createDate;return this;}
	
	/**
	 * 修改时间
	 */
	public java.util.Date getModifiedDate() {return modifiedDate;}
	
	/**
	 * 修改时间
	 */
	protected Account setModifiedDate(java.util.Date modifiedDate) {this.modifiedDate = modifiedDate;return this;}
	
	
	// 代理
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected Object[] getFKTableNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return FK_SOURCE_TABLE_NAMES;
		case PINGYING:
			return FK_PINGYING_TABLE_NAMES;
		case HASHCODE:
			return FK_HASHCODE_TABLE_NAMES;
		default:
			return FK_PINGYING_TABLE_NAMES;
		}
	}
	
	protected Object[] getFKColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return FK_SOURCE_COLUMN_NAMES;
		case PINGYING:
			return FK_PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return FK_HASHCODE_COLUMN_NAMES;
		default:
			return FK_PINGYING_TABLE_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected String[] getColumnTypes(){
		return COLUMN_COLUMNTYPES;
	}
	
	protected int getColumnCount(){
		return COLUMN_COUNT;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.accountId;
        values[2] = this.channelId;
        values[3] = this.channelAppId;
        values[4] = this.password;
        values[5] = this.email;
        values[6] = this.deviceToken;
        values[7] = this.deviceName;
        values[8] = this.deviceId;
        values[9] = this.sdk;
        values[10] = this.sdkVersion;
        values[11] = this.osName;
        values[12] = this.osVersion;
        values[13] = this.phoneNumber;
        values[14] = this.clientVersion;
        values[15] = this.question;
        values[16] = this.answer;
        values[17] = this.admin;
        values[18] = this.gameServerId;
        values[19] = this.language;
        values[20] = this.ip;
        values[21] = this.lastOnlineTime;
        values[22] = this.lastOfflineTime;
        values[23] = this.state;
        values[24] = this.onlineState;
        values[25] = this.activate;
        values[26] = this.createDate;
        values[27] = this.modifiedDate;
        return values;
	}
	
	public Account deepCopy(){
		Account account = null;
		try {
			account = (Account) super.clone();
		    account.setLastOnlineTime(ToolCopy.copyObject(this.lastOnlineTime));
		    account.setLastOfflineTime(ToolCopy.copyObject(this.lastOfflineTime));
		    account.setCreateDate(ToolCopy.copyObject(this.createDate));
		    account.setModifiedDate(ToolCopy.copyObject(this.modifiedDate));
		    // 克隆索引
		    account.indexValues = ArrayUtils.clone(indexValues);
			return account;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return account;
	}
	
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.accountId);
        map.put(keys[2], this.channelId);
        map.put(keys[3], this.channelAppId);
        map.put(keys[4], this.password);
        map.put(keys[5], this.email);
        map.put(keys[6], this.deviceToken);
        map.put(keys[7], this.deviceName);
        map.put(keys[8], this.deviceId);
        map.put(keys[9], this.sdk);
        map.put(keys[10], this.sdkVersion);
        map.put(keys[11], this.osName);
        map.put(keys[12], this.osVersion);
        map.put(keys[13], this.phoneNumber);
        map.put(keys[14], this.clientVersion);
        map.put(keys[15], this.question);
        map.put(keys[16], this.answer);
        map.put(keys[17], this.admin);
        map.put(keys[18], this.gameServerId);
        map.put(keys[19], this.language);
        map.put(keys[20], this.ip);
        map.put(keys[21], this.lastOnlineTime);
        map.put(keys[22], this.lastOfflineTime);
        map.put(keys[23], this.state);
        map.put(keys[24], this.onlineState);
        map.put(keys[25], this.activate);
        map.put(keys[26], this.createDate);
        map.put(keys[27], this.modifiedDate);
        return map;
    }
    
    protected Account createForMap(Object[] keys,Map map){
   		this.id = (String)map.get(keys[0]);
   		this.accountId = (String)map.get(keys[1]);
   		this.channelId = (int)map.get(keys[2]);
   		this.channelAppId = (int)map.get(keys[3]);
   		this.password = (String)map.get(keys[4]);
   		this.email = (String)map.get(keys[5]);
   		this.deviceToken = (String)map.get(keys[6]);
   		this.deviceName = (String)map.get(keys[7]);
   		this.deviceId = (String)map.get(keys[8]);
   		this.sdk = (String)map.get(keys[9]);
   		this.sdkVersion = (String)map.get(keys[10]);
   		this.osName = (String)map.get(keys[11]);
   		this.osVersion = (String)map.get(keys[12]);
   		this.phoneNumber = (String)map.get(keys[13]);
   		this.clientVersion = (String)map.get(keys[14]);
   		this.question = (String)map.get(keys[15]);
   		this.answer = (String)map.get(keys[16]);
   		this.admin = (boolean)map.get(keys[17]);
   		this.gameServerId = (String)map.get(keys[18]);
   		this.language = (String)map.get(keys[19]);
   		this.ip = (String)map.get(keys[20]);
   		this.lastOnlineTime = (java.util.Date)map.get(keys[21]);
   		this.lastOfflineTime = (java.util.Date)map.get(keys[22]);
   		this.state = (int)map.get(keys[23]);
   		this.onlineState = (int)map.get(keys[24]);
   		this.activate = (boolean)map.get(keys[25]);
   		this.createDate = (java.util.Date)map.get(keys[26]);
   		this.modifiedDate = (java.util.Date)map.get(keys[27]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.accountId);
        obj.put(keys[2], this.channelId);
        obj.put(keys[3], this.channelAppId);
        obj.put(keys[4], this.password);
        obj.put(keys[5], this.email);
        obj.put(keys[6], this.deviceToken);
        obj.put(keys[7], this.deviceName);
        obj.put(keys[8], this.deviceId);
        obj.put(keys[9], this.sdk);
        obj.put(keys[10], this.sdkVersion);
        obj.put(keys[11], this.osName);
        obj.put(keys[12], this.osVersion);
        obj.put(keys[13], this.phoneNumber);
        obj.put(keys[14], this.clientVersion);
        obj.put(keys[15], this.question);
        obj.put(keys[16], this.answer);
        obj.put(keys[17], this.admin);
        obj.put(keys[18], this.gameServerId);
        obj.put(keys[19], this.language);
        obj.put(keys[20], this.ip);
        obj.put(keys[21], this.lastOnlineTime);
        obj.put(keys[22], this.lastOfflineTime);
        obj.put(keys[23], this.state);
        obj.put(keys[24], this.onlineState);
        obj.put(keys[25], this.activate);
        obj.put(keys[26], this.createDate);
        obj.put(keys[27], this.modifiedDate);
        return obj;
    }
    
    protected Account createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getString(keys[0]);
	    this.accountId = obj.getString(keys[1]);
	    this.channelId = obj.getIntValue(keys[2]);
	    this.channelAppId = obj.getIntValue(keys[3]);
	    this.password = obj.getString(keys[4]);
	    this.email = obj.getString(keys[5]);
	    this.deviceToken = obj.getString(keys[6]);
	    this.deviceName = obj.getString(keys[7]);
	    this.deviceId = obj.getString(keys[8]);
	    this.sdk = obj.getString(keys[9]);
	    this.sdkVersion = obj.getString(keys[10]);
	    this.osName = obj.getString(keys[11]);
	    this.osVersion = obj.getString(keys[12]);
	    this.phoneNumber = obj.getString(keys[13]);
	    this.clientVersion = obj.getString(keys[14]);
	    this.question = obj.getString(keys[15]);
	    this.answer = obj.getString(keys[16]);
	    this.admin = obj.getBooleanValue(keys[17]);
	    this.gameServerId = obj.getString(keys[18]);
	    this.language = obj.getString(keys[19]);
	    this.ip = obj.getString(keys[20]);
	    this.lastOnlineTime = obj.getDate(keys[21]);
	    this.lastOfflineTime = obj.getDate(keys[22]);
	    this.state = obj.getIntValue(keys[23]);
	    this.onlineState = obj.getIntValue(keys[24]);
	    this.activate = obj.getBooleanValue(keys[25]);
	    this.createDate = obj.getDate(keys[26]);
	    this.modifiedDate = obj.getDate(keys[27]);
        return this;
    }
    
    
    public Account createForResultSet(ResultSet rs) throws SQLException{
	    this.id = rs.getString(SOURCE_COLUMN_NAMES[0]);
	    this.accountId = rs.getString(SOURCE_COLUMN_NAMES[1]);
	    this.channelId = rs.getInt(SOURCE_COLUMN_NAMES[2]);
	    this.channelAppId = rs.getInt(SOURCE_COLUMN_NAMES[3]);
	    this.password = rs.getString(SOURCE_COLUMN_NAMES[4]);
	    this.email = rs.getString(SOURCE_COLUMN_NAMES[5]);
	    this.deviceToken = rs.getString(SOURCE_COLUMN_NAMES[6]);
	    this.deviceName = rs.getString(SOURCE_COLUMN_NAMES[7]);
	    this.deviceId = rs.getString(SOURCE_COLUMN_NAMES[8]);
	    this.sdk = rs.getString(SOURCE_COLUMN_NAMES[9]);
	    this.sdkVersion = rs.getString(SOURCE_COLUMN_NAMES[10]);
	    this.osName = rs.getString(SOURCE_COLUMN_NAMES[11]);
	    this.osVersion = rs.getString(SOURCE_COLUMN_NAMES[12]);
	    this.phoneNumber = rs.getString(SOURCE_COLUMN_NAMES[13]);
	    this.clientVersion = rs.getString(SOURCE_COLUMN_NAMES[14]);
	    this.question = rs.getString(SOURCE_COLUMN_NAMES[15]);
	    this.answer = rs.getString(SOURCE_COLUMN_NAMES[16]);
	    this.admin = rs.getBoolean(SOURCE_COLUMN_NAMES[17]);
	    this.gameServerId = rs.getString(SOURCE_COLUMN_NAMES[18]);
	    this.language = rs.getString(SOURCE_COLUMN_NAMES[19]);
	    this.ip = rs.getString(SOURCE_COLUMN_NAMES[20]);
	    this.lastOnlineTime = rs.getTimestamp(SOURCE_COLUMN_NAMES[21]);
	    this.lastOfflineTime = rs.getTimestamp(SOURCE_COLUMN_NAMES[22]);
	    this.state = rs.getInt(SOURCE_COLUMN_NAMES[23]);
	    this.onlineState = rs.getInt(SOURCE_COLUMN_NAMES[24]);
	    this.activate = rs.getBoolean(SOURCE_COLUMN_NAMES[25]);
	    this.createDate = rs.getTimestamp(SOURCE_COLUMN_NAMES[26]);
	    this.modifiedDate = rs.getTimestamp(SOURCE_COLUMN_NAMES[27]);
	    return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeString(this.id);
	    byteBuf.writeString(this.accountId);
	    byteBuf.writeInt(this.channelId);
	    byteBuf.writeInt(this.channelAppId);
	    byteBuf.writeString(this.password);
	    byteBuf.writeString(this.email);
	    byteBuf.writeString(this.deviceToken);
	    byteBuf.writeString(this.deviceName);
	    byteBuf.writeString(this.deviceId);
	    byteBuf.writeString(this.sdk);
	    byteBuf.writeString(this.sdkVersion);
	    byteBuf.writeString(this.osName);
	    byteBuf.writeString(this.osVersion);
	    byteBuf.writeString(this.phoneNumber);
	    byteBuf.writeString(this.clientVersion);
	    byteBuf.writeString(this.question);
	    byteBuf.writeString(this.answer);
	    byteBuf.writeBoolean(this.admin);
	    byteBuf.writeString(this.gameServerId);
	    byteBuf.writeString(this.language);
	    byteBuf.writeString(this.ip);
	    byteBuf.writeDate(this.lastOnlineTime);
	    byteBuf.writeDate(this.lastOfflineTime);
	    byteBuf.writeInt(this.state);
	    byteBuf.writeInt(this.onlineState);
	    byteBuf.writeBoolean(this.activate);
	    byteBuf.writeDate(this.createDate);
	    byteBuf.writeDate(this.modifiedDate);
    }
	
	protected Account readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readString(null);
	    this.accountId = byteBuf.readString(null);
	    this.channelId = byteBuf.readInt(null);
	    this.channelAppId = byteBuf.readInt(null);
	    this.password = byteBuf.readString(null);
	    this.email = byteBuf.readString(null);
	    this.deviceToken = byteBuf.readString(null);
	    this.deviceName = byteBuf.readString(null);
	    this.deviceId = byteBuf.readString(null);
	    this.sdk = byteBuf.readString(null);
	    this.sdkVersion = byteBuf.readString(null);
	    this.osName = byteBuf.readString(null);
	    this.osVersion = byteBuf.readString(null);
	    this.phoneNumber = byteBuf.readString(null);
	    this.clientVersion = byteBuf.readString(null);
	    this.question = byteBuf.readString(null);
	    this.answer = byteBuf.readString(null);
	    this.admin = byteBuf.readBoolean(null);
	    this.gameServerId = byteBuf.readString(null);
	    this.language = byteBuf.readString(null);
	    this.ip = byteBuf.readString(null);
	    this.lastOnlineTime = byteBuf.readDate(null);
	    this.lastOfflineTime = byteBuf.readDate(null);
	    this.state = byteBuf.readInt(null);
	    this.onlineState = byteBuf.readInt(null);
	    this.activate = byteBuf.readBoolean(null);
	    this.createDate = byteBuf.readDate(null);
	    this.modifiedDate = byteBuf.readDate(null);
	    return this;
	}
    
    
    protected JSONObject exportFKTableMap(Object[] keys,JSONObject map,DataModelKeyEnum e){
        return map;
    }
    
    protected boolean importFKTableMap(Object[] keys,JSONObject map,DataModelKeyEnum e){
		return true;
    }
    
	/** 取得[channel]*/
	public Channel getChannelPkChannelId(){
		return ChannelCache.me().getById(channelId);
	}
	/** 取得[channel_app]*/
	public ChannelApp getChannelAppPkChannelAppId(){
		return ChannelAppCache.me().getById(channelAppId);
	}
	
    /** 级联删除(延迟入库) */
    public boolean deleteAndSon(){
    	return false;
    }
    
    /** 级联删除(及时入库) */
    public boolean deleteAndSonAndFlush(){
    	return false;
    }
    
    /** 延迟插入数据库 */
    public Account insert(){
    	return AccountCache.me().insert(this);
    }
    /** 延迟更新数据库 */
    public Account update(){
    	return AccountCache.me().update(this);
    }
    /** 延迟删除数据库 */
    public boolean delete(){
    	return AccountCache.me().delete(this);
    }
    /** 即时插入数据库 */
    public Account insertAndFlush(){
    	return AccountCache.me().insertAndFlush(this);
    }
    /** 即时更新数据库 */
    public Account updateAndFlush(){
    	return AccountCache.me().updateAndFlush(this);
    }
    /** 即时删除数据库 */
    public boolean deleteAndFlush(){
    	return AccountCache.me().deleteAndFlush(this);
    }
    
    
	
	/**
	 * 同步索引值
	 */
	public Account syncIndexValues(){
		indexValues[0] = SK_Plus.b(getId()).e();
		indexValues[1] = SK_Plus.b(getAccountId(),"_",getChannelId()).e();
		indexValues[2] = SK_Plus.b(getChannelId()).e();
		indexValues[3] = SK_Plus.b(getChannelAppId()).e();
		indexValues[4] = SK_Plus.b(getGameServerId()).e();
		return this;
	}
	/**
	 * 取得索引
	 */
	public String[] getIndexValues(){
		return indexValues;
	}
	
	protected Object getPrimaryKey(){
		return getId();
	}
	
	protected void setPrimaryKey(Object key){
		setId((String)key);
	}
//自定义内容起始位置
//自定义内容结束位置
}